package com.shenda.api.web;

import java.util.concurrent.CompletableFuture;

import com.shenda.api.dto.ConfigDTO;
import com.shenda.api.entity.Gyro;
import com.shenda.api.service.GyroServiceAsync;
import com.swak.annotation.FluxReferer;
import com.swak.annotation.PostMapping;
import com.swak.annotation.RestApi;
import com.swak.entity.Parameters;
import com.swak.entity.Result;
import com.swak.utils.Functions;

/**
 * 陀螺仪 -- 管理
 * 
 * @author lifeng
 */
@RestApi(path = "/api/admin/gyro", value = "adminGyroApi")
public class GyroApi {

	@FluxReferer
	private GyroServiceAsync gyroService;

	/**
	 * 在线设备
	 * 
	 * @return
	 */
	@PostMapping("/onlines")
	public CompletableFuture<Result> onlines() {
		return gyroService.onlines().thenApply(Functions.resultFunction());
	}

	/**
	 * 刷新操作
	 * 
	 * @return
	 */
	@PostMapping("/options/refresh")
	public CompletableFuture<Result> refresh() {
		return gyroService.refresh().thenApply(Functions.resultFunction());
	}

	/**
	 * 配置操作
	 * 
	 * @return
	 */
	@PostMapping("/options/config")
	public CompletableFuture<Result> config(ConfigDTO config) {
		return gyroService.config(config).thenApply(Functions.resultFunction());
	}

	/**
	 * 采集
	 * 
	 * @return
	 */
	@PostMapping("/options/gather")
	public CompletableFuture<Result> gather() {
		return gyroService.gather().thenApply(Functions.resultFunction());
	}

	/**
	 * 停止采集
	 * 
	 * @return
	 */
	@PostMapping("/options/ungather")
	public CompletableFuture<Result> ungather() {
		return gyroService.ungather().thenApply(Functions.resultFunction());
	}

	/**
	 * 上传
	 * 
	 * @return
	 */
	@PostMapping("/options/upload")
	public CompletableFuture<Result> upload() {
		return gyroService.upload().thenApply(Functions.resultFunction());
	}

	/**
	 * 停止上传
	 * 
	 * @return
	 */
	@PostMapping("/options/unupload")
	public CompletableFuture<Result> unupload() {
		return gyroService.unupload().thenApply(Functions.resultFunction());
	}

	/**
	 * 清除
	 * 
	 * @return
	 */
	@PostMapping("/options/flush")
	public CompletableFuture<Result> flush() {
		return gyroService.flush().thenApply(Functions.resultFunction());
	}

	/**
	 * 重启
	 * 
	 * @return
	 */
	@PostMapping("/options/reboot")
	public CompletableFuture<Result> reboot() {
		return gyroService.reboot().thenApply(Functions.resultFunction());
	}

	/**
	 * 关闭
	 * 
	 * @return
	 */
	@PostMapping("/options/close")
	public CompletableFuture<Result> close() {
		return gyroService.close().thenApply(Functions.resultFunction());
	}

	/**
	 * 分页查询
	 * 
	 * @param query
	 * @param param
	 * @return
	 */
	@PostMapping("/page")
	public CompletableFuture<Result> page(Gyro query, Parameters param) {
		return gyroService.page(query, param).thenApply(Functions.resultFunction());
	}
}